import java.util.Arrays;

/**
 * @Author YuanYuan
 * @Date 2022/5/7
 * @Time 10:11
 */
public class TestDemo {
    public static void bubbleSort(int[] arr) {
        int len = arr.length;
        for (int i = 0; i < arr.length-1; i++) {
            int flag = 0;
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                    flag = 1;
                }
            }
            if(0 == flag) {
                break;
            }
        }
    }
    public static void main(String[] args) {
        int[] arr = {2,3,4,1,7,5};
        bubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
